/*
 * Brandon T. Andersen
 * 1000878186
 * Spring 2012
 * CSE 460 / 598
 * Online Graduate Student
 * 
 * Tip Calculator Version 2
 * 
 * UserGUI.java
 * 
 */
package tipcalculator;

// Imports
import java.util.ArrayList;
import javax.swing.JSlider;
import javax.swing.JTextField;

/*
 *
 * UserGUI Class extands a JFrame and handles all user input, validation and
 * calcuations As a user interacts with various features, the GUI updates
 * dynamically based on the user input.
 *
 */
public class UserGUI extends javax.swing.JFrame
{

    // Private member fields
    private Bill bill = null;
    private TipCalculatorView tipCalculatorView = null;
    private ArrayList<JTextField> guestList;
    private ArrayList<JSlider> guestRatings;
    private ArrayList<JTextField> guestTips;

    /**
     * UserGUI Constructor to initialize the interface
     */
    public UserGUI()
    {
        initComponents();

        this.tipCalculatorView = TipCalculatorView.getInstance();
        this.bill = tipCalculatorView.createBill();

        // These ArrayLists are used for future expansion of number of users
        this.guestList = new ArrayList<JTextField>();
        this.guestRatings = new ArrayList<JSlider>();
        this.guestTips = new ArrayList<JTextField>();

        // Initialize the ArrayLists, for future versions, this can be done
        // using dynamically created objects rather than specifying members
        this.guestList.add(this.guest1);
        this.guestList.add(this.guest2);
        this.guestList.add(this.guest3);
        this.guestList.add(this.guest4);
        this.guestList.add(this.guest5);
        this.guestList.add(this.guest6);
        this.guestList.add(this.guest7);
        this.guestList.add(this.guest8);
        this.guestList.add(this.guest9);

        this.guestRatings.add(this.guest1rating);
        this.guestRatings.add(this.guest2rating);
        this.guestRatings.add(this.guest3rating);
        this.guestRatings.add(this.guest4rating);
        this.guestRatings.add(this.guest5rating);
        this.guestRatings.add(this.guest6rating);
        this.guestRatings.add(this.guest7rating);
        this.guestRatings.add(this.guest8rating);
        this.guestRatings.add(this.guest9rating);

        this.guestTips.add(this.guest1Tip);
        this.guestTips.add(this.guest2Tip);
        this.guestTips.add(this.guest3Tip);
        this.guestTips.add(this.guest4Tip);
        this.guestTips.add(this.guest5Tip);
        this.guestTips.add(this.guest6Tip);
        this.guestTips.add(this.guest7Tip);
        this.guestTips.add(this.guest8Tip);
        this.guestTips.add(this.guest9Tip);

        // Initialize all the fields to start with default values
        this.numberOfGuests.setSelectedIndex(0);
        this.overallRating.setValue(3);
        this.statusText.setText("OK");
        this.update();

        for (int i = 0; i < this.guestList.size(); i++)
        {
            this.guestRatings.get(i).setValue(3);

            if (i >= this.getNumberOfGuests())
            {
                this.guestList.get(i).setEnabled(false);
                this.guestRatings.get(i).setEnabled(false);
            }

            this.guestTips.get(i).setEditable(false);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTextField16 = new javax.swing.JTextField();
        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        overallRating = new javax.swing.JSlider();
        jLabel3 = new javax.swing.JLabel();
        numberOfGuests = new javax.swing.JComboBox();
        billAmountText = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        billDeductions = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        tax = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        tipRate = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        totalTip = new javax.swing.JTextField();
        tipPerPersonLabel = new javax.swing.JLabel();
        tipPerPerson = new javax.swing.JTextField();
        total = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        useTipTailoring = new javax.swing.JCheckBox();
        jPanel2 = new javax.swing.JPanel();
        guest1 = new javax.swing.JTextField();
        guest1rating = new javax.swing.JSlider();
        guest2rating = new javax.swing.JSlider();
        guest3rating = new javax.swing.JSlider();
        guest4rating = new javax.swing.JSlider();
        guest5rating = new javax.swing.JSlider();
        guest6rating = new javax.swing.JSlider();
        guest7rating = new javax.swing.JSlider();
        guest8rating = new javax.swing.JSlider();
        guest9rating = new javax.swing.JSlider();
        guest2 = new javax.swing.JTextField();
        guest3 = new javax.swing.JTextField();
        guest4 = new javax.swing.JTextField();
        guest5 = new javax.swing.JTextField();
        guest6 = new javax.swing.JTextField();
        guest7 = new javax.swing.JTextField();
        guest8 = new javax.swing.JTextField();
        guest9 = new javax.swing.JTextField();
        guest1Tip = new javax.swing.JTextField();
        guest2Tip = new javax.swing.JTextField();
        guest3Tip = new javax.swing.JTextField();
        guest4Tip = new javax.swing.JTextField();
        guest5Tip = new javax.swing.JTextField();
        guest6Tip = new javax.swing.JTextField();
        guest7Tip = new javax.swing.JTextField();
        guest8Tip = new javax.swing.JTextField();
        guest9Tip = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        minTipPercent = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        maxTipPercent = new javax.swing.JTextField();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel14 = new javax.swing.JLabel();
        includeTax = new javax.swing.JCheckBox();
        includeDeductions = new javax.swing.JCheckBox();
        jLabel15 = new javax.swing.JLabel();
        statusText = new javax.swing.JTextField();

        jTextField16.setText("jTextField16");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(480, 800));
        setResizable(false);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Tip Splitting Calculator");

        jLabel2.setText("Number of Guests");

        overallRating.setMajorTickSpacing(1);
        overallRating.setMaximum(5);
        overallRating.setMinimum(1);
        overallRating.setPaintLabels(true);
        overallRating.setPaintTicks(true);
        overallRating.setToolTipText("Modifies the tip percent based on the minimum and maximum ranges specified in the settings.");
        overallRating.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                overallRatingStateChanged(evt);
            }
        });

        jLabel3.setText("Quality of Service (1 - Poor, 5 Excellent)");

        numberOfGuests.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9" }));
        numberOfGuests.setToolTipText("Select the total number of guest, including yourself.");
        numberOfGuests.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                numberOfGuestsActionPerformed(evt);
            }
        });

        billAmountText.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        billAmountText.setText("20.00");
        billAmountText.setToolTipText("The dollar amount of the bill, before taxes or deductions. Enter a numeric value greater than or equal to zero.");
        billAmountText.setName("");
        billAmountText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                billAmountTextActionPerformed(evt);
            }
        });

        jLabel4.setText("Bill Amount ($)");

        billDeductions.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        billDeductions.setText("0.00");
        billDeductions.setToolTipText("Amount to subtract from the bill amount for discounts, coupons, etc...");
        billDeductions.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                billDeductionsActionPerformed(evt);
            }
        });

        jLabel5.setText("Bill Deductions ($)");

        tax.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        tax.setText("0.00");
        tax.setToolTipText("The total tax in dollars.");
        tax.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                taxActionPerformed(evt);
            }
        });

        jLabel6.setText("Tax ($)");

        jLabel7.setText("Tip Rate (%)");

        tipRate.setEditable(false);
        tipRate.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        tipRate.setText("jTextField4");
        tipRate.setToolTipText("Determined from the specified range in settings and the Quality of Service rating, where a rating of 3 gives the midpoint value between the minimum and maximum tip percent. A 1 yields the minimum and a 5 the maximum tip percentage.");

        jLabel8.setText("Total Tip ($)");

        totalTip.setEditable(false);
        totalTip.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        totalTip.setText("jTextField5");
        totalTip.setToolTipText("Either the total tip based on the Tip Per Person value multiplied by the Number of Guests, or if tailored tipping is used, the sum of each individual's tailored tip amount.");

        tipPerPersonLabel.setText("Tip Per Person ($)");

        tipPerPerson.setEditable(false);
        tipPerPerson.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        tipPerPerson.setText("jTextField6");
        tipPerPerson.setToolTipText("If tailored tipping is not used, this will be the per person amount to put in for the tip. If tailored tipping is used, this is not applicable.");

        total.setEditable(false);
        total.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        total.setText("jTextField7");
        total.setToolTipText("The total bill including deductions, taxes and tips.");

        jLabel10.setText("Total ($)");

        useTipTailoring.setText("Check to Use Tailored Tip Values in Totals");
        useTipTailoring.setToolTipText("Check this box to use the Tip Tailoring screen in you calculations.");
        useTipTailoring.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                useTipTailoringActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(overallRating, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(numberOfGuests, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tipPerPersonLabel)
                            .addComponent(jLabel10)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(tax)
                            .addComponent(billDeductions)
                            .addComponent(billAmountText)
                            .addComponent(total, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE)
                            .addComponent(tipPerPerson)
                            .addComponent(totalTip)
                            .addComponent(tipRate)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel7)
                            .addComponent(useTipTailoring))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(numberOfGuests, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(overallRating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(billAmountText))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(billDeductions))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tax))
                .addGap(22, 22, 22)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tipRate))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tipPerPerson, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tipPerPersonLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(totalTip)
                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(total)
                    .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(useTipTailoring)
                .addGap(211, 211, 211))
        );

        jTabbedPane2.addTab("Bill Entry", jPanel1);

        guest1.setText("Guest 1");
        guest1.setToolTipText("Enter a guest name here for ease of assign tip amounts.");

        guest1rating.setMajorTickSpacing(1);
        guest1rating.setMaximum(5);
        guest1rating.setPaintLabels(true);
        guest1rating.setPaintTicks(true);
        guest1rating.setToolTipText("Modifies the tip percent based on the minimum and maximum ranges specified in the settings. For an individual, this will treat their portion as if the entire group tipped at the rate selected by the individual.");
        guest1rating.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                guest1ratingStateChanged(evt);
            }
        });

        guest2rating.setMajorTickSpacing(1);
        guest2rating.setMaximum(5);
        guest2rating.setPaintLabels(true);
        guest2rating.setPaintTicks(true);
        guest2rating.setToolTipText("Modifies the tip percent based on the minimum and maximum ranges specified in the settings. For an individual, this will treat their portion as if the entire group tipped at the rate selected by the individual.");
        guest2rating.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                guest2ratingStateChanged(evt);
            }
        });

        guest3rating.setMajorTickSpacing(1);
        guest3rating.setMaximum(5);
        guest3rating.setPaintLabels(true);
        guest3rating.setPaintTicks(true);
        guest3rating.setToolTipText("Modifies the tip percent based on the minimum and maximum ranges specified in the settings. For an individual, this will treat their portion as if the entire group tipped at the rate selected by the individual.");
        guest3rating.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                guest3ratingStateChanged(evt);
            }
        });

        guest4rating.setMajorTickSpacing(1);
        guest4rating.setMaximum(5);
        guest4rating.setPaintLabels(true);
        guest4rating.setPaintTicks(true);
        guest4rating.setToolTipText("Modifies the tip percent based on the minimum and maximum ranges specified in the settings. For an individual, this will treat their portion as if the entire group tipped at the rate selected by the individual.");
        guest4rating.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                guest4ratingStateChanged(evt);
            }
        });

        guest5rating.setMajorTickSpacing(1);
        guest5rating.setMaximum(5);
        guest5rating.setPaintLabels(true);
        guest5rating.setPaintTicks(true);
        guest5rating.setToolTipText("Modifies the tip percent based on the minimum and maximum ranges specified in the settings. For an individual, this will treat their portion as if the entire group tipped at the rate selected by the individual.");
        guest5rating.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                guest5ratingStateChanged(evt);
            }
        });

        guest6rating.setMajorTickSpacing(1);
        guest6rating.setMaximum(5);
        guest6rating.setPaintLabels(true);
        guest6rating.setPaintTicks(true);
        guest6rating.setToolTipText("Modifies the tip percent based on the minimum and maximum ranges specified in the settings. For an individual, this will treat their portion as if the entire group tipped at the rate selected by the individual.");
        guest6rating.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                guest6ratingStateChanged(evt);
            }
        });

        guest7rating.setMajorTickSpacing(1);
        guest7rating.setMaximum(5);
        guest7rating.setPaintLabels(true);
        guest7rating.setPaintTicks(true);
        guest7rating.setToolTipText("Modifies the tip percent based on the minimum and maximum ranges specified in the settings. For an individual, this will treat their portion as if the entire group tipped at the rate selected by the individual.");
        guest7rating.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                guest7ratingStateChanged(evt);
            }
        });

        guest8rating.setMajorTickSpacing(1);
        guest8rating.setMaximum(5);
        guest8rating.setPaintLabels(true);
        guest8rating.setPaintTicks(true);
        guest8rating.setToolTipText("Modifies the tip percent based on the minimum and maximum ranges specified in the settings. For an individual, this will treat their portion as if the entire group tipped at the rate selected by the individual.");
        guest8rating.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                guest8ratingStateChanged(evt);
            }
        });

        guest9rating.setMajorTickSpacing(1);
        guest9rating.setMaximum(5);
        guest9rating.setPaintLabels(true);
        guest9rating.setPaintTicks(true);
        guest9rating.setToolTipText("Modifies the tip percent based on the minimum and maximum ranges specified in the settings. For an individual, this will treat their portion as if the entire group tipped at the rate selected by the individual.");
        guest9rating.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                guest9ratingStateChanged(evt);
            }
        });

        guest2.setText("Guest 2");
        guest2.setToolTipText("Enter a guest name here for ease of assign tip amounts.");

        guest3.setText("Guest 3");
        guest3.setToolTipText("Enter a guest name here for ease of assign tip amounts.");

        guest4.setText("Guest 4");
        guest4.setToolTipText("Enter a guest name here for ease of assign tip amounts.");

        guest5.setText("Guest 5");
        guest5.setToolTipText("Enter a guest name here for ease of assign tip amounts.");

        guest6.setText("Guest 6");
        guest6.setToolTipText("Enter a guest name here for ease of assign tip amounts.");

        guest7.setText("Guest 7");
        guest7.setToolTipText("Enter a guest name here for ease of assign tip amounts.");

        guest8.setText("Guest 8");
        guest8.setToolTipText("Enter a guest name here for ease of assign tip amounts.");

        guest9.setText("Guest 9");
        guest9.setToolTipText("Enter a guest name here for ease of assign tip amounts.");

        guest1Tip.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        guest1Tip.setText("0.00");
        guest1Tip.setToolTipText("The tip amount for this guest.");

        guest2Tip.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        guest2Tip.setText("0.00");
        guest2Tip.setToolTipText("The tip amount for this guest.");

        guest3Tip.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        guest3Tip.setText("0.00");
        guest3Tip.setToolTipText("The tip amount for this guest.");

        guest4Tip.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        guest4Tip.setText("0.00");
        guest4Tip.setToolTipText("The tip amount for this guest.");

        guest5Tip.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        guest5Tip.setText("0.00");
        guest5Tip.setToolTipText("The tip amount for this guest.");

        guest6Tip.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        guest6Tip.setText("0.00");
        guest6Tip.setToolTipText("The tip amount for this guest.");

        guest7Tip.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        guest7Tip.setText("0.00");
        guest7Tip.setToolTipText("The tip amount for this guest.");

        guest8Tip.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        guest8Tip.setText("0.00");
        guest8Tip.setToolTipText("The tip amount for this guest.");

        guest9Tip.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        guest9Tip.setText("0.00");
        guest9Tip.setToolTipText("The tip amount for this guest.");

        jLabel9.setText("Individual Tip ($)");

        jLabel16.setText("Individual Tip ($)");

        jLabel17.setText("Individual Tip ($)");

        jLabel18.setText("Individual Tip ($)");

        jLabel19.setText("Individual Tip ($)");

        jLabel20.setText("Individual Tip ($)");

        jLabel21.setText("Individual Tip ($)");

        jLabel22.setText("Individual Tip ($)");

        jLabel23.setText("Individual Tip ($)");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(guest1)
                    .addComponent(guest2)
                    .addComponent(guest3)
                    .addComponent(guest4)
                    .addComponent(guest5)
                    .addComponent(guest6)
                    .addComponent(guest7)
                    .addComponent(guest8)
                    .addComponent(guest9)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel23)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(guest9Tip, javax.swing.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(guest1Tip))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(guest2Tip))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(guest3Tip))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel18)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(guest4Tip))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel19)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(guest5Tip))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel20)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(guest6Tip))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel21)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(guest7Tip))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel22)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(guest8Tip)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(guest1rating, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
                    .addComponent(guest2rating, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)
                    .addComponent(guest3rating, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(guest4rating, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)
                    .addComponent(guest5rating, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)
                    .addComponent(guest6rating, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)
                    .addComponent(guest7rating, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)
                    .addComponent(guest8rating, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)
                    .addComponent(guest9rating, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(guest1rating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(guest1Tip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(guest1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel9)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(guest2rating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(guest2Tip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(guest2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel16)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(guest3rating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(guest3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(guest3Tip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel17))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(guest4rating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(guest4Tip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(guest4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel18)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(guest5rating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(guest5Tip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(guest5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel19)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(guest6rating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(guest6Tip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(guest6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel20)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(guest7rating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(guest7Tip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(guest7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel21)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(guest8rating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(guest8Tip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(guest8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel22)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(guest9rating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(guest9Tip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(guest9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel23)))
                .addContainerGap(34, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab("Tip Tailoring", jPanel2);

        jLabel11.setText("Tip Range - Set a minimum and maximum (0 - 100%)");

        minTipPercent.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        minTipPercent.setText("0.00");
        minTipPercent.setToolTipText("Enter a numeric value for the minimum tip percentage.");
        minTipPercent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                minTipPercentActionPerformed(evt);
            }
        });

        jLabel12.setText("Minimum Tip Percentage (from 0 to Max)");

        jLabel13.setText("Maximum Tip Percentage (from Min - 100)");

        maxTipPercent.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        maxTipPercent.setText("40.00");
        maxTipPercent.setToolTipText("Enter a numeric value for the maximum tip percentage.");
        maxTipPercent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                maxTipPercentActionPerformed(evt);
            }
        });

        jLabel14.setText("Tip Base - Select which items to include in determining tip");

        includeTax.setText("Include Tax");
        includeTax.setToolTipText("Check this box to include the Tax amount in the tip calculation.");
        includeTax.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                includeTaxActionPerformed(evt);
            }
        });

        includeDeductions.setSelected(true);
        includeDeductions.setText("Include Deductions");
        includeDeductions.setToolTipText("Check this box to subtract deductions from the Bill Amount prior to calculating the tip.");
        includeDeductions.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                includeDeductionsActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator2)
                    .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12)
                            .addComponent(includeDeductions)
                            .addComponent(includeTax))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(maxTipPercent)
                            .addComponent(minTipPercent))))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(minTipPercent)
                    .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(maxTipPercent)
                    .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(includeTax)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(includeDeductions)
                .addContainerGap(346, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab("Settings", jPanel3);

        jLabel15.setText("Status:");

        statusText.setText("OK");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(statusText))
                    .addComponent(jTabbedPane2))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(statusText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // Event handler for when the number of guests input is updated
    private void numberOfGuestsActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_numberOfGuestsActionPerformed
    {//GEN-HEADEREND:event_numberOfGuestsActionPerformed
        this.updateGuestList();
        this.bill.numGuests = this.getNumberOfGuests();
        this.update();
    }//GEN-LAST:event_numberOfGuestsActionPerformed

    // Event handler for when the overall rating input is updated
    private void overallRatingStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_overallRatingStateChanged
    {//GEN-HEADEREND:event_overallRatingStateChanged
        this.bill.overallRating = this.overallRating.getValue();
        this.update();
    }//GEN-LAST:event_overallRatingStateChanged

    // Event handler for when the bill amount input is updated
    private void billAmountTextActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_billAmountTextActionPerformed
    {//GEN-HEADEREND:event_billAmountTextActionPerformed
        // First try to convert the user supplied input to a double
        try
        {
            double billAmount = Double.parseDouble(this.billAmountText.getText());

            // if it is numeric and convertible, do some range checks
            if (billAmount >= 0)
            {
                this.bill.billAmount = billAmount;
                this.statusMessage("OK");
            }
            else
            {
                this.statusMessage("Invalid Bill Amount - Negative");
            }
        }
        catch (NumberFormatException e)
        {
            // User tried to enter a non-numeric value
            this.statusMessage("Invalid Bill Amount - Not Numeric");
        }

        this.update();
    }//GEN-LAST:event_billAmountTextActionPerformed

    // Event handler for when the bill deduction input is updated
    private void billDeductionsActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_billDeductionsActionPerformed
    {//GEN-HEADEREND:event_billDeductionsActionPerformed
        // First try to convert the user supplied input to a double
        try
        {
            double deductionAmount = Double.parseDouble(this.billDeductions.getText());

            // if it is numeric and convertible, do some range checks
            if ((deductionAmount >= 0) && (deductionAmount <= bill.billAmount))
            {
                this.bill.deductionAmount = deductionAmount;
                this.statusMessage("OK");
            }
            else
            {
                this.statusMessage("Invalid Bill Deductions - Negative or Exceeds Bill");
            }
        }
        catch (NumberFormatException e)
        {
            // User tried to enter a non-numeric value
            this.statusMessage("Invalid Bill Deductions - Not Numeric");
        }

        this.update();
    }//GEN-LAST:event_billDeductionsActionPerformed

    // Event handler for when the tax amount input is updated
    private void taxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_taxActionPerformed
    {//GEN-HEADEREND:event_taxActionPerformed
        // First try to convert the user supplied input to a double
        try
        {
            double taxAmount = Double.parseDouble(this.tax.getText());

            // if it is numeric and convertible, do some range checks
            if ((taxAmount >= 0) && (taxAmount <= this.bill.billAmount))
            {
                this.bill.taxAmount = taxAmount;
                this.statusMessage("OK");
            }
            else
            {
                this.statusMessage("Invalid Tax - Negative or Exceeds Bill");
            }
        }
        catch (NumberFormatException e)
        {
            // User tried to enter a non-numeric value
            this.statusMessage("Invalid Tax Amount - Not Numeric");
        }

        this.update();
    }//GEN-LAST:event_taxActionPerformed

    // Event handler for when the min tip pct input is updated
    private void minTipPercentActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_minTipPercentActionPerformed
    {//GEN-HEADEREND:event_minTipPercentActionPerformed
        // First try to convert the user supplied input to a double
        try
        {
            double minTipPercent = Double.parseDouble(this.minTipPercent.getText());

            // if it is numeric and convertible, do some range checks
            if ((minTipPercent >= 0) && (minTipPercent <= 100) && (minTipPercent <= this.bill.maxTipPercent))
            {
                this.bill.minTipPercent = minTipPercent;
                this.statusMessage("OK");
            }
            else
            {
                this.statusMessage("Invalid Min Tip - Exceeds Max or Out-of-Range");
            }
        }
        catch (NumberFormatException e)
        {
            // User tried to enter a non-numeric value
            this.statusMessage("Invalid Min Tip - Not Numeric");
        }

        this.update();
    }//GEN-LAST:event_minTipPercentActionPerformed

    // Event handler for when the max tip pct input is updated
    private void maxTipPercentActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_maxTipPercentActionPerformed
    {//GEN-HEADEREND:event_maxTipPercentActionPerformed
        // First try to convert the user supplied input to a double
        try
        {
            double maxTipPercent = Double.parseDouble(this.maxTipPercent.getText());

            // if it is numeric and convertible, do some range checks
            if ((maxTipPercent >= 0) && (maxTipPercent <= 100) && (maxTipPercent >= this.bill.minTipPercent))
            {
                this.bill.maxTipPercent = maxTipPercent;
                this.statusMessage("OK");
            }
            else
            {
                this.statusMessage("Invalid Max Tip - Less Than Min or Out-of-Range");
            }
        }
        catch (NumberFormatException e)
        {
            // User tried to enter a non-numeric value
            this.statusMessage("Invalid Max Tip - Not Numeric");
        }

        this.update();
    }//GEN-LAST:event_maxTipPercentActionPerformed

    /*
     * These next methods simply handle events for the associated inputs and
     * call the update() method to refresh the GUI for new values
     */
    private void guest1ratingStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_guest1ratingStateChanged
    {//GEN-HEADEREND:event_guest1ratingStateChanged
        this.bill.guestRatings.set(0, this.guestRatings.get(0).getValue());
        this.update();
    }//GEN-LAST:event_guest1ratingStateChanged

    private void guest2ratingStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_guest2ratingStateChanged
    {//GEN-HEADEREND:event_guest2ratingStateChanged
        this.bill.guestRatings.set(1, this.guestRatings.get(1).getValue());
        this.update();
    }//GEN-LAST:event_guest2ratingStateChanged

    private void guest3ratingStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_guest3ratingStateChanged
    {//GEN-HEADEREND:event_guest3ratingStateChanged
        this.bill.guestRatings.set(2, this.guestRatings.get(2).getValue());
        this.update();
    }//GEN-LAST:event_guest3ratingStateChanged

    private void guest4ratingStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_guest4ratingStateChanged
    {//GEN-HEADEREND:event_guest4ratingStateChanged
        this.bill.guestRatings.set(3, this.guestRatings.get(3).getValue());
        this.update();
    }//GEN-LAST:event_guest4ratingStateChanged

    private void guest5ratingStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_guest5ratingStateChanged
    {//GEN-HEADEREND:event_guest5ratingStateChanged
        this.bill.guestRatings.set(4, this.guestRatings.get(4).getValue());
        this.update();
    }//GEN-LAST:event_guest5ratingStateChanged

    private void guest6ratingStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_guest6ratingStateChanged
    {//GEN-HEADEREND:event_guest6ratingStateChanged
        this.bill.guestRatings.set(5, this.guestRatings.get(5).getValue());
        this.update();
    }//GEN-LAST:event_guest6ratingStateChanged

    private void guest7ratingStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_guest7ratingStateChanged
    {//GEN-HEADEREND:event_guest7ratingStateChanged
        this.bill.guestRatings.set(6, this.guestRatings.get(6).getValue());
        this.update();
    }//GEN-LAST:event_guest7ratingStateChanged

    private void guest8ratingStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_guest8ratingStateChanged
    {//GEN-HEADEREND:event_guest8ratingStateChanged
        this.bill.guestRatings.set(7, this.guestRatings.get(7).getValue());
        this.update();
    }//GEN-LAST:event_guest8ratingStateChanged

    private void guest9ratingStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_guest9ratingStateChanged
    {//GEN-HEADEREND:event_guest9ratingStateChanged
        this.bill.guestRatings.set(8, this.guestRatings.get(8).getValue());
        this.update();
    }//GEN-LAST:event_guest9ratingStateChanged

    private void includeTaxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_includeTaxActionPerformed
    {//GEN-HEADEREND:event_includeTaxActionPerformed
        this.bill.includeTax = this.includeTax.isSelected();
        this.update();
    }//GEN-LAST:event_includeTaxActionPerformed

    private void includeDeductionsActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_includeDeductionsActionPerformed
    {//GEN-HEADEREND:event_includeDeductionsActionPerformed
        this.bill.includeDeductions = this.includeDeductions.isSelected();
        this.update();
    }//GEN-LAST:event_includeDeductionsActionPerformed

    // Event handler for selecting the option to use tip tailoring
    private void useTipTailoringActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_useTipTailoringActionPerformed
    {//GEN-HEADEREND:event_useTipTailoringActionPerformed
        // If selected for use, let the user know with GUI update
        if (this.useTipTailoring.isSelected())
        {
            this.tipPerPersonLabel.setText("Tip Per Person (Tailored)");
        }
        else
        {
            this.tipPerPersonLabel.setText("Tip Per Person ($)");
        }

        this.bill.tipTailoring = this.useTipTailoring.isSelected();
        this.update();
    }//GEN-LAST:event_useTipTailoringActionPerformed

    // Update method calls several other methods to update the tips and totals
    // based on the processed bill
    private void update()
    {
        // This signals the view that an event has occurred in the GUI
        // and the bill is passed for processing and the process bill
        // is returned
        this.bill = this.tipCalculatorView.updateView(bill);
        // Set the bill amount field
        this.billAmountText.setText(this.tipCalculatorView.getBillAmount());
        // Set the bill deductions field
        this.billDeductions.setText(this.tipCalculatorView.getDeductionAmount());
        // Set the tax field
        this.tax.setText(this.tipCalculatorView.getTaxAmount());
        // Set the min tip percent field
        this.minTipPercent.setText(this.tipCalculatorView.getMinTipPercent());
        // Set the max tip percent filed
        this.maxTipPercent.setText(this.tipCalculatorView.getMaxTipPercent());
        // Set the tip rate filed
        this.tipRate.setText(this.tipCalculatorView.getTipRate());
        // Set the per person tip field
        this.tipPerPerson.setText(this.tipCalculatorView.getTipPerPerson());
        // Dim the per person tip value if tailoring is used
        this.tipPerPerson.setEnabled(!this.tipCalculatorView.getTipTailoring());
        // Set the total tip field
        this.totalTip.setText(this.tipCalculatorView.getTipTotal());
        // Set the total field
        this.total.setText(this.tipCalculatorView.getTotal());
        // Set the individual tailored tip for each guest
        for (int i = 0; i < this.getNumberOfGuests(); i++)
        {
            this.guestTips.get(i).setText(this.tipCalculatorView.getGuestTip(i));
        }
    }

    // This method updates the guest list depending on how many guests are selected
    private void updateGuestList()
    {
        for (int i = 0; i < this.guestList.size(); i++)
        {
            this.guestList.get(i).setEnabled(i < this.getNumberOfGuests());
            this.guestRatings.get(i).setEnabled(i < this.getNumberOfGuests());
            this.guestTips.get(i).setEnabled(i < this.getNumberOfGuests());
        }
    }

    // Simply gets the number of guests
    private int getNumberOfGuests()
    {
        return (this.numberOfGuests.getSelectedIndex() + 1);
    }

    // Updates the status message with messages for the user
    private void statusMessage(String str)
    {
        this.statusText.setText(str);
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField billAmountText;
    private javax.swing.JTextField billDeductions;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JTextField guest1;
    private javax.swing.JTextField guest1Tip;
    private javax.swing.JSlider guest1rating;
    private javax.swing.JTextField guest2;
    private javax.swing.JTextField guest2Tip;
    private javax.swing.JSlider guest2rating;
    private javax.swing.JTextField guest3;
    private javax.swing.JTextField guest3Tip;
    private javax.swing.JSlider guest3rating;
    private javax.swing.JTextField guest4;
    private javax.swing.JTextField guest4Tip;
    private javax.swing.JSlider guest4rating;
    private javax.swing.JTextField guest5;
    private javax.swing.JTextField guest5Tip;
    private javax.swing.JSlider guest5rating;
    private javax.swing.JTextField guest6;
    private javax.swing.JTextField guest6Tip;
    private javax.swing.JSlider guest6rating;
    private javax.swing.JTextField guest7;
    private javax.swing.JTextField guest7Tip;
    private javax.swing.JSlider guest7rating;
    private javax.swing.JTextField guest8;
    private javax.swing.JTextField guest8Tip;
    private javax.swing.JSlider guest8rating;
    private javax.swing.JTextField guest9;
    private javax.swing.JTextField guest9Tip;
    private javax.swing.JSlider guest9rating;
    private javax.swing.JCheckBox includeDeductions;
    private javax.swing.JCheckBox includeTax;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTextField jTextField16;
    private javax.swing.JTextField maxTipPercent;
    private javax.swing.JTextField minTipPercent;
    private javax.swing.JComboBox numberOfGuests;
    private javax.swing.JSlider overallRating;
    private javax.swing.JTextField statusText;
    private javax.swing.JTextField tax;
    private javax.swing.JTextField tipPerPerson;
    private javax.swing.JLabel tipPerPersonLabel;
    private javax.swing.JTextField tipRate;
    private javax.swing.JTextField total;
    private javax.swing.JTextField totalTip;
    private javax.swing.JCheckBox useTipTailoring;
    // End of variables declaration//GEN-END:variables
}
